﻿#region License statement
// NJamb, a specification and delta-specification DSL
// Copyright (c) 2010-2011, Mark Knell
// Published under the MIT License; all other rights reserved
#endregion

#region using...
using NJamb.Specifications.Delta;
using NUnit.Framework;
using Rhino.Mocks;
using Stile.Patterns.SelfDescribingPredicates;
#endregion

namespace NJamb.Tests.Specifications.Delta
{
    [TestFixture]
    public class DeltaSpecificationFixture
    {
        private IEvaluable<IEvaluation<string>> _before;
        private IEvaluable<IEvaluation<string>> _evaluationAfter;
        private IEvaluation<string> _evaluationBefore;
        private DeltaSpecification<string> _testSubject;

        [SetUp]
        public void Init()
        {
            _before = MockRepository.GenerateStub<IEvaluable<IEvaluation<string>>>();
            _evaluationBefore = MockRepository.GenerateStub<IEvaluation<string>>();
            _before.Stub(x => x.Evaluate()).Return(_evaluationBefore);
            _evaluationAfter = MockRepository.GenerateStub<IEvaluable<IEvaluation<string>>>();
            _testSubject = new DeltaSpecification<string>(_before, _evaluationAfter);
        }

        [Test]
        public void EvaluatePrecondition()
        {
            // arrange

            // act
            IPreconditionEvaluation preconditionEvaluation = _testSubject.EvaluatePrecondition();

            // assert
            Assert.That(preconditionEvaluation.Evaluation, Is.SameAs(_evaluationBefore));
            Assert.That(preconditionEvaluation.GetPostcondition(), Is.SameAs(_evaluationAfter));
        }
    }
}
